//
//  HRRegestViewModel.m
//  Hear
//
//  Created by mac on 2017/3/29.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HRRegestViewModel.h"
#import "HRVerificationCodeModel.h"
#import "HRRegisterModel.h"
@implementation HRRegestViewModel
-(void)getVerificationCodeParam:(HRReuestCodeModel *)paramDict andRegestResult:(void(^)(NSDictionary *result))regestResult
{
    YTKApi *api = [YTKApi apiGetWithUrl:@"UserInfo/Get_VerificationCode" parameter:paramDict];
    [api getSuccessToken:^() {
        [api setRequestSerializerType:YTKRequestSerializerTypeJSON];
        [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
            
            
            regestResult(request.responseJSONObject);
        } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
//            loginResult(NO);
        }];
    }];

}

- (void)registerUserParam:(HRRegisterRequstModel *)paramDict andResult:(void(^)(NSDictionary *result))result{
    YTKApi *api = [YTKApi apiPostWithUrl:@"UserInfo/Post_UserRegisterInfo" parameter:paramDict];
    [api getSuccessToken:^() {
        [api setRequestSerializerType:YTKRequestSerializerTypeHTTP];
        [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
            NSDictionary *dict = request.responseJSONObject;
            if ([dict[@"CodeStatus"] intValue] == 20000){
                result(request.responseJSONObject);
            }else{
                result(nil);
            }
        } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
            result(nil);
            DDLog(@" ---------- registe false");
        }];
    }];

}


-(void)checkIsRegisterUser:(NSDictionary *)paramDict andResult:(void(^)(NSDictionary *result))result{
    YTKApi *api = [YTKApi apiGetWithUrl:@"UserInfo/Get_GetOtherLogin" para:paramDict];
    [api getSuccessToken:^() {
        [api setRequestSerializerType:YTKRequestSerializerTypeJSON];
        [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
            result(request.responseJSONObject);
            
        } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
            result(nil);
        }];
    }];
};

-(void)checkMobileIsReg:(NSDictionary *)paramDict andResult:(void(^)(NSDictionary *result))result{
    YTKApi *api = [YTKApi apiGetWithUrl:@"UserInfo/Get_CheckMobileIsReg" para:paramDict];
    [api getSuccessToken:^() {
        [api setRequestSerializerType:YTKRequestSerializerTypeJSON];
        [api startWithSuccess:^(YTKBaseRequest *request) {
            result(request.responseJSONObject);
        }];
    }];
};



@end
